<template>
  <div class="account-form">
    <el-form :inline="true" :model="inputForm">
      <div class="displays">
        <el-form-item label="账号" class="letterSpacing displays w22 mr22">
          <el-input
            v-model="inputForm.userName"
            size="small"
            placeholder="请输入账号"
          ></el-input>
        </el-form-item>
        <el-form-item label="员工姓名" class="displays w22 mr22">
          <el-input
            v-model="inputForm.realName"
            size="small"
            placeholder="请输入员工姓名"
          ></el-input>
        </el-form-item>
        <el-form-item label="角色" class="letterSpacing displays w22 mr22">
          <el-select
            v-model="inputForm.roleId"
            size="small"
            @click.native="handleRoleList"
            @change="handleChange(inputForm.roleId)"
            clearable
            placeholder="请选择"
          >
            <el-option
              v-for="item in options"
              :key="item._id"
              :label="item.name"
              :value="item._id"
            ></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="联系方式" class="displays w22 mr22">
          <el-input
            v-model="inputForm.phone"
            size="small"
            placeholder="请输入联系方式"
          ></el-input>
        </el-form-item>

        <div class="displays w12">
          <el-button type="primary" size="small" @click="handleSearch"
            >查询</el-button
          >
          <el-button size="small" @click="handleReset" class="resletBtn"
            >重置</el-button
          >
          <el-button type="text" size="small" @click="openShow()">{{
            isShow ? "高级搜索" : "收起"
          }}</el-button>
        </div>
      </div>
      <div v-show="!isShow" class="two displays">
        <el-form-item label="帐号状态" class="displays w22 mr22">
          <el-select
            v-model="inputForm.status"
            size="small"
            clearable
            placeholder="请选择"
          >
            <el-option label="停用" value="500"></el-option>
            <el-option label="正常" value="200"></el-option>
          </el-select>
        </el-form-item>
      </div>
    </el-form>
  </div>
</template>

<script>
import { getAllroles } from "@/api/user.js";
export default {
  data() {
    return {
      inputForm: {
        userName: "",
        realName: "",
        roleId: "",
        phone: "",
        status: "",
      },
      options: [],
      _id: "",
      isShow: true,
    };
  },
  methods: {
    // 展开按钮
    openShow() {
      this.isShow = !this.isShow;
      this.$emit("isShow", this.isShow);
    },
    handleSearch() {
      this.$emit("Search", this.inputForm);
    },
    handleReset() {
      this.inputForm.userName = "";
      this.inputForm.realName = "";
      this.inputForm.roleId = "";
      this.inputForm.phone = "";
      this.inputForm.status = "";
      this.$emit("Search", this.inputForm);
    },
    handleRoleList() {
      getAllroles().then((res) => {
        this.options = res.result;
      });
    },
    //选中的角色
    handleChange(val) {
      this._id = val;
    },
  },
};
</script>

<style scoped lang="scss">
::v-deep .el-input__inner {
  border-radius: 0px 2px 2px 0px !important;
}
.two {
  margin-top: 10px;
}
.w22 {
  width: 21.5%;
}
// .w12 {
//   width: 14%;
// }
.mr22 {
  padding-right: 16px;
  box-sizing: border-box;
}
.letterSpacing {
  ::v-deep .el-form-item__label {
    text-align: right !important;
    letter-spacing: 18px !important;
  }
}
.displays {
  display: flex;
  align-items: center;
  ::v-deep .el-form-item__label {
    width: 76px !important;
    background: #F0F0F0;
    text-align: center;
    font-weight: 400 !important;
    color: #1A2035;
  }
  ::v-deep .el-form-item__content {
    flex: 1;
    .el-date-editor,
    .el-range-editor,
    .el-input__inner .el-date-editor--daterange .el-range-editor--small,
    .el-date-editor--daterange.el-input__inner,
    .el-select {
      width: 100% !important;
    }
  }
}
</style>